package main

// Definition for singly-linked list.
type ListNode struct {
	Val  int
	Next *ListNode
}

func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
	head := l1
	carry := 0
	for {
		l1.Val += l2.Val + carry
		carry = l1.Val / 10
		l1.Val %= 10
		if l1.Next == nil && l2.Next == nil && carry == 0 {
			break
		}
		if l1.Next == nil {
			l1.Next = &ListNode{}
		}
		if l2.Next == nil {
			l2.Next = &ListNode{}
		}
		l1, l2 = l1.Next, l2.Next
	}
	return head
}

func main() {

}
